package com.ht.system.api.factory;

import com.ht.common.core.domain.R;
import com.ht.system.api.RemoteBaseFieldInfoService;
import com.ht.system.api.RemoteEnterpriseInfoService;
import com.ht.system.api.dto.BaseFieldInfoDto;
import com.ht.system.api.dto.EnterpriseDto;
import com.ht.system.api.dto.EnterpriseInfoDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 场站信息服务降级处理
 *
 * @author zmx
 */
@Component
public class RemoteEnterpriseInfoFallbackFactory implements FallbackFactory<RemoteEnterpriseInfoService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteEnterpriseInfoFallbackFactory.class);

    @Override
    public RemoteEnterpriseInfoService create(Throwable throwable) {
        return new RemoteEnterpriseInfoService() {
            @Override
            public R<EnterpriseInfoDto> findAllByEntCode(String entCode, String source) {
                return R.fail("获取企业信息服务失败:" + throwable.getMessage());
            }

            @Override
            public R<EnterpriseInfoDto> findByEntCode(String entCode, String source) {
                return R.fail("获取企业信息服务失败:" + throwable.getMessage());
            }

            @Override
            public R<List<EnterpriseDto>> findAllEnterprise(String source) {
                return R.fail("获取企业信息列表失败:" + throwable.getMessage());
            }
        };
    }
}
